home *** CD-ROM | disk | FTP | other *** search
- /***********************************************************
- Yahoo
- ***********************************************************/
- var supportInboxOnly=true;
- var supportShowFolders=true;
-
- function init(){
- this.initStage=ST_PRE;
- var ar=this.user.split("@");
- if(ar[1]=="yahoo.co.jp"){
- this.loginData=["https://login.yahoo.co.jp/config/login?",
- "","passwd","login="+encodeURIComponent(ar[0])];
- this.dataURL="http://mail.yahoo.co.jp/"
- this.mailURL="http://mail.yahoo.co.jp/";
- this.mailDomain="mail.yahoo.co.jp";
- this.domain="yahoo.co.jp";
- if(this.getCookie("yahoo.co.jp","Y")!=null)this.loginData[3]+="&.persistent=y";
- }else{
- this.loginData=["https://login.yahoo.com/config/login?",
- "login","passwd"];
- this.dataURL="http://mail.yahoo.com/"
- this.mailURL="http://mail.yahoo.com/";
- this.mailDomain="mail.yahoo.com";
- this.domain="yahoo.com";
- if(this.getCookie("yahoo.com","Y")!=null)this.loginData[3]+="&.persistent=y";
- }
- }
-
- function process(aHttpChannel, aData) {
- switch(this.stage){
- case ST_PRE:
- this.mode=-1;
- this.getHtml(this.dataURL);
- return false;
- case ST_PRE_RES:
- this.stage=ST_LOGIN;
- break;
- case ST_LOGIN_RES:
- var fnd=aData.match(/<input.+?type="hidden".+?name=".secdata".+?value="(.+?)".*?>/);
- if(fnd){
- if(this.main.prefBranch.getBoolPref("yahoo.showCaptcha")){
- var rs=this.main.openCaptchaDialog(this.id,this.user,"https://ab.login.yahoo.com/img/"+fnd[1]+".jpg");
- if(rs){
- this.getHtml(this.loginData[LOGIN_URL],this.loginData[LOGIN_POST]+"&.secdata="+encodeURIComponent(fnd[1])+"&.secword="+encodeURIComponent(rs));
- return false;
- }
- }
- /*var ck=this.getCookieString("yahoo.com","F");
- if(ck){
- this.cookieManager.addCookies("http://login.yahoo.com",ck);
- this.getHtml(this.loginData[LOGIN_URL],this.loginData[LOGIN_POST]);
- return false;
- }*/
- this.onError();
- return true;
- }
- this.stage=ST_DATA;
- break;
- case (ST_LOGIN_RES+1):
- this.stage=ST_DATA;
- break;
- case (ST_DATA_RES):
- var fnd=aData.match(/doAction\(\'2\',\s*?\'(\S+?)\'/);
- if(fnd){//not supported os
- try{
- var location=aHttpChannel.getResponseHeader("Location");
- location=location.match(/\S+yahoo.com/);
- this.getHtml(location+"/dc/system_requirements.php","a=2&crumb="+encodeURIComponent(fnd[1]));
- return false;
- }catch(e){}
- }
- break;
- case (ST_DATA_RES+1):
- this.stage=ST_DATA;
- break;
- }
- return this.baseProcess(aHttpChannel, aData);
- }
- /*
- //without this, keep asking captcha code
- function onRequest(aHttpChannel){
- WebMailHandler.prototype.onRequest.call(this,aHttpChannel);
- if(this.stage==this.initStage){
- var ck=this.getCookieString("yahoo.com","F");
- if(ck)this.cookieManager.addCookies(aHttpChannel.URI,ck);
- }
- }
- */
- //without this, keep asking captcha code
- function onRequest(aHttpChannel){
- WebMailHandler.prototype.onRequest.call(this,aHttpChannel);
- if(this.stage==this.initStage){
- var done=false;
- try{
- var s=this.main.prefBranch.getCharPref("accounts."+this.id+"."+this.user+".cookie");
- s=s.split("\t");
- var ioService = Components.classes["@mozilla.org/network/io-service;1"]
- .getService(Components.interfaces.nsIIOService);
- var uri=ioService.newURI(s[0],null,null);
- this.cookieManager.addCookies(uri,s[1]);
- done=true;
- }catch(e){}
- if(!done){
- var ck=this.getCookieString(this.domain,"F");
- if(ck){
- this.cookieManager.addCookies("http://login."+this.domain,ck);
- }
- }
-
- /* if(!done){
- var ck=this.getCookieString("yahoo.com","F");
- if(ck){
- this.cookieManager.addCookies(aHttpChannel.URI,ck);
- this.main.prefBranch.setCharPref("accounts."+this.id+"."+this.user+".cookie",aHttpChannel.URI.spec+"\t"+ck);
- }
- }*/
- }
- }
- function onResponse(aHttpChannel){
- /* try {
- var cookie = aHttpChannel.getResponseHeader("Set-Cookie");
- if(cookie.match(/^F=/m))dout(this.stage+"###"+this.user+" "+cookie);
- }catch(e){}*/
- WebMailHandler.prototype.onResponse.call(this,aHttpChannel);
- if(this.stage==(ST_LOGIN_RES+1)){
- var s=this.cookieManager.findCookie(aHttpChannel.URI.spec,"F");
- if(s){
- this.main.prefBranch.setCharPref("accounts."+this.id+"."+this.user+".cookie",aHttpChannel.URI.spec+"\t"+s);
- }
- }
- }
- function getCount(aData){
- return this.mailCount;
- }
- function getData(aData){
- var obj={};
- var ar=[];
- this.folders={};//used for direct link
- if(this.mode<0){
- var fnd=aData.match(/<div.+?folderlist.+?>([\s\S]+?)<div class=\"last\">/);
- this.mode=fnd?1:0;
- }
- if(this.mode==1){//original mode
- var fnd=aData.match(/<div.+?folderlist.+?>([\s\S]+?)<div class=\"last\">/);
- fnd=fnd[1];
- if(!this.inboxOnly||this.showFolders){
- var fnd2=aData.match(/<div.+?customfolders.+?>([\s\S]+?)<div class=\"last\">/);
- if(fnd2){
- fnd+=fnd2[1];
- }
- }
- fnd=fnd.match(/<li .+?<\/a>/g);
- if(fnd){
- var s;
- var num=0;
- for each(s in fnd){
- var t=s.match(/li\s+id=\"(.+?)\".+?<a.+?>(?:<em>)?(.+?)(?:\s\S+(\d+)\S+)?<\/a>/);
- if(t){
- if(t[1]=="draft"||t[1]=="sent"||t[1]=="receipt"
- ||t[1]=="bulk"||t[1]=="trash")continue;
- var n=0;
- if(t[3])n=parseInt(t[3]);
- if(this.inboxOnly){
- if(t[1]=="inbox")num=n;
- }else num+=n;
- if(n>0&&t[1]!="inbox"){
- var fid=t[1];
- if(fid.indexOf("%")==0)fid=fid.substring(1,fid.length-1);
- this.folders[t[2]]=fid;
- ar.push(t[2]);
- ar.push(n);
- }
- }
- }
- this.mailCount=num;
- if(this.showFolders){
- if(ar)obj.folders=encodeArray(ar);
- }
- return obj;
- }
- }else{
- fnd=aData.match(/<ListFoldersResponse>([\s\S]+?)<\/ListFoldersResponse>/);
- if(fnd){
- fnd=fnd[1].match(/<folder.+?<\/folder>/g);
- if(fnd){
- var s;
- var num=0;
- for each(s in fnd){
- s=s.match(/unread=\\?\"(\d+)\\?\".+?fid=\\?\"(.+?)\\?\".+?name=\\?\"(.+?)\\?\"/);
- if(s){
- if(s[2]=="%40B%40Bulk"||s[2]=="Draft"
- ||s[2]=="Sent"||s[2]=="Trash")continue;
- var n=0;
- if(s[1])n=parseInt(s[1]);
- if(this.inboxOnly){
- if(s[2]=="Inbox")num=n;
- }else num+=n;
- if(n>0&&s[2]!="Inbox"){
- var name=s[3];
- name=unescape(name.replace(/(\w+);/g,function(){return "%u"+RegExp.$1;}));
- ar.push(name);
- ar.push(n);
- }
- }
- }
- this.mailCount=num;
- if(this.showFolders){
- if(ar)obj.folders=encodeArray(ar);
- }
- return obj;
- }
- }
- }
- this.mailCount=-1;
- return obj;
- }
- function getMailURL(aFolder){
- if(this.mode==1&&aFolder&&this.dataURLCopy){
- var n=this.dataURLCopy.indexOf("/",7);
- var url=this.dataURLCopy.substring(0,n)
- +"/mc/showFolder?fid="+encodeURIComponent(this.folders[aFolder]);
- return url;
- }
- return this.mailURL;
- }
-